// 快速MCP连接测试
const { ToolManager } = require('../dist/tools/index.js');

async function quickMCPTest() {
    const toolManager = new ToolManager();
    
    console.log('🚀 快速MCP连接测试\n');
    
    // 连接参数
    const serverConfig = {
        name: 'fs-server',
        command: 'node index.js',
        cwd: 'E:\\mcp_server\\mcp_server\\out'
    };
    
    console.log(`连接到: ${serverConfig.cwd}`);
    console.log(`命令: ${serverConfig.command}\n`);
    
    try {
        // 1. 连接
        console.log('🔗 正在连接...');
        const connectResult = await toolManager.executeTool('mcp-client', {
            action: 'connect',
            serverName: serverConfig.name,
            command: serverConfig.command,
            cwd: serverConfig.cwd
        });
        
        if (connectResult.includes('✅')) {
            console.log('✅ 连接成功！\n');
            
            // 2. 列出工具
            console.log('🔧 获取可用工具...');
            const toolsResult = await toolManager.executeTool('mcp-client', {
                action: 'list-tools',
                serverName: serverConfig.name
            });
            console.log(toolsResult);
            
            // 3. 断开连接
            console.log('\n❌ 断开连接...');
            await toolManager.executeTool('mcp-client', {
                action: 'disconnect',
                serverName: serverConfig.name
            });
            console.log('✅ 已断开连接');
            
        } else {
            console.log('❌ 连接失败:');
            console.log(connectResult);
        }
        
    } catch (error) {
        console.error('❌ 错误:', error.message);
    }
}

quickMCPTest();